from sqlalchemy import Column, Integer, String, DateTime, func

from datetime import datetime

from module_admin.entity.do.base import db


class Comment(db.Model):
    __tablename__ = 'sys_comments'

    id = Column(Integer, primary_key=True, autoincrement=True, comment='评论ID')
    post_id = Column(Integer,nullable=True, comment='文章ID')
    commenter_type = Column(String(10), nullable=False, comment="评论者类型：'student' 或 'teacher'")
    student_name = Column(String(500), nullable=True, comment='学生name')
    teacher_name = Column(String(500), nullable=True, comment='教师name')
    content = Column(String(500), nullable=False, comment='评论内容')
    parent_comment_id = Column(Integer, nullable=True, comment='父评论ID')
    # 自动生成 create_time 字段，默认使用当前时间
    create_time = Column(DateTime, server_default=func.now(), comment='创建时间')
